class Factory {
    private FruitHandler chain;

    public Factory() {
        // 构建责任链
        AppleHandler appleHandler = new AppleHandler();
        BananaHandler bananaHandler = new BananaHandler();
        appleHandler.setNext(bananaHandler);
        chain = appleHandler;
    }

    public Fruit CreateFruit(String kind) {
        return chain.handleRequest(kind);
    }
}